<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //1.创建一个盒子并用变量div存储
        var div = document.createElement("div");
        //2.创建一个文本节点并用变量text存储
        var text = document.createTextNode('Hello World');
        //3.把文本节点加入盒子里
        div.appendChild(text);
        //4.把盒子放到body标签内
        document.body.appendChild(div);
        //console.log(text);
    </script>

</body>

</html>